<?php


namespace Packages\Statistics\Controllers\Admin;


use App\Http\Controllers\Controller;
use Packages\Statistics\Services\StatisticsService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class StatisticsController extends Controller
{
    protected $statisticsService;

    public function __construct(statisticsService $statisticsService)
    {
        $this->statisticsService = $statisticsService;
    }

    /**
     * 用户统计
     * @param Request $request
     * @return JsonResponse
     */
    public function userCount(Request $request)
    {
        // 定义业务参数验证规则
        $params = $this->validateParams($request, []);

        $res = $this->statisticsService->userCount($params);

        return $this->returnResponse($res);
    }

    /**
     * 订单统计
     * @param Request $request
     * @return JsonResponse
     */
    public function orderCount(Request $request)
    {
        // 定义业务参数验证规则
        $params = $this->validateParams($request, []);

        $res = $this->statisticsService->orderCount($params);

        return $this->returnResponse($res);
    }

    /**
     * 产品统计
     * @param Request $request
     * @return JsonResponse
     */
    public function productCount(Request $request)
    {
        // 定义业务参数验证规则
        $params = $this->validateParams($request, []);

        $res = $this->statisticsService->productCount($params);

        return $this->returnResponse($res);
    }

    /**
     * 任务统计
     * @param Request $request
     * @return JsonResponse
     */
    public function taskCount(Request $request)
    {
        // 定义业务参数验证规则
        $params = $this->validateParams($request, []);

        $res = $this->statisticsService->taskCount($params);

        return $this->returnResponse($res);
    }
}
